import wx  
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas  
from matplotlib.figure import Figure  
  
class MyFrame(wx.Frame):  
    def __init__(self, title):  
        super(MyFrame, self).__init__(None, title=title, size=(600, 400))  
  
        # 创建一个面板并添加画布  
        self.panel = wx.Panel(self)  

        # 创建一个 matplotlib 图表  
        self.figure = Figure()  
        self.axes = self.figure.add_subplot(111)  
        self.axes.plot([1, 2, 3, 4, 5], [1, 4, 2, 5, 3])  
  
        # 创建一个 matplotlib 图表画布  
        self.canvas = FigureCanvas(self.panel, -1, self.figure)  
  
        
        sizer = wx.BoxSizer(wx.VERTICAL)  
        sizer.Add(self.canvas, 1, wx.EXPAND | wx.ALL, 5)  
        self.panel.SetSizer(sizer)  
  
        # 显示窗口  
        self.Show()  
  
if __name__ == '__main__':  
    app = wx.App(False)  
    frame = MyFrame('wxPython with Matplotlib')  
    app.MainLoop()
    